package String测试;

import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class Test
{
    public static void main(String[] args) throws IntrospectionException, InvocationTargetException,
                                                  IllegalAccessException
    {
        Student student = new Student();
        String[] strings = new String[]{"aaa","bbb"};


        Map<String, String[]> map = new HashMap<>();

        map.put("aaa",strings);
        Class<Student> studentClass = Student.class;
        PropertyDescriptor propertyDescriptor = new PropertyDescriptor("hobby",studentClass);

        Method writeMethod = propertyDescriptor.getWriteMethod();
        writeMethod.invoke(student, strings);


        System.out.println(student);

        PropertyDescriptor propertyDescriptor1 = new PropertyDescriptor("name",studentClass);

        Method writeMethod1 = propertyDescriptor.getWriteMethod();
        writeMethod.invoke(student,map.get("aaa"));
        System.out.println(student);


    }
}
